const http = require('http');
const fs = require('fs');
const url = require('url');
let sever = http.createServer((request,response)=>{
    response.setHeader('Content-Type', 'text/html;charset=utf8');
    let pathname = url.parse(request.url,true).pathname;
    if(pathname == '/')
    {
        response.end(fs.readFileSync('./index.html'));
    }
    if(pathname == '/login')
    {
        let obj = url.parse(request.url,true).query;
        if(obj.username == 'axj' && obj.password == '123')
        {
            response.end('登录成功');
        }
        else
        {
            response.end('登录失败');
        }
    }
})
sever.listen(3000,()=>{
    console.log('已经启动成功，访问端口localhost:3000');
})